package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取当前目录下所有的文件(当前目录下的子目录不要)
 */
public class Demo4 {
    public static void main(String[] args) {
        File file = new File(".");
        if (file.isDirectory()){
            FileFilter str = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    return file.isFile();
                }
            };
            File[] subs = file.listFiles(str);
            System.out.println(subs.length);
            for (int i = 0; i < subs.length; i++) {
                File sub = subs[i];
                System.out.println(sub.getName());
            }
        }
    }
}
